class UsersController < ApplicationController
  before_filter :authenticate_user!

  rescue_from 'ActiveRecord::RecordNotFound' do
    render :text => "not found"
  end

  def profile
    if params[:id].nil?
      @user = current_user
    else
      @user = User.find params[:id]
    end
  end

  def edit
    @user = current_user
  end

  def update
    @user = current_user
    @user.update_attributes params[:user]
    #@user.name = params[:name] unless params.nil?
    #unless params[:latitude].nil? or params[:longitude].nil?
    #  @user.latitude, user.longitude = patams[:latitude].to_f, params[:longitude].to_f
    #  @user.save
    #end
    redirect_to current_profile_path
  end

  def set_location
    @user = current_user
    @user.update_attributes(:latitude => params[:latitude], :longitude => params[:longitude])
    render :json => { :response => 'ok' }.to_json, :status => :ok
  end

end
